package com.shuwen.gcdj.job;

import com.shuwen.gcdj.common.util.webSocket.SimpMessagingTemplateUtils;
import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @projeceName: hddjapi
 * @ClassName DemoJob
 * @description:
 * @author: tzhang
 * @create: 2023-05-17 09:50
 * @Version 1.0
 **/
@Component
@Slf4j
public class DemoJob {

    @Autowired
    private SimpMessagingTemplateUtils simpMessagingTemplateUtils;

    @XxlJob("demoJob")
    public void demo() {
        //获取参数
        String jobParam = XxlJobHelper.getJobParam();
        log.info("demo job");
    }

/*    @XxlJob("plancyclemanagementScheduled")
    public void demo1() {
        //设备分组 key 设备编码 value 数据
        List<StatisticsRealtimePlcResp> stats = Lists.newArrayList();

        Map<String, List<StatisticsRealtimePlcResp>> gruopDate = stats.stream().collect(Collectors.groupingBy(StatisticsRealtimePlcResp::getEquipmentCode));
        for (Map.Entry<String, List<StatisticsRealtimePlcResp>> data : gruopDate.entrySet()) {

            simpMessagingTemplateUtils.sendMessageToSubject("/topic/greetings/"+data.getKey(),
                    NoticeWebsocketResult.data(data.getValue(), "1"));
        }
        //每个组推一次
        log.info("demo job");
    }*/
}